<template>
  <div>
      <el-upload
        :class="'avatar-uploader '+ clazz"
        action=""
        :show-file-list="false"
        :on-success="handleAvatarSuccess"
        :before-upload="beforeAvatarUpload"
        >
        <img v-if="imageUrl" :src="imageUrl" class="avatar">
        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
      </el-upload>
  </div>
</template>

<script>
  import {uploadOssFile} from '@/shop/util/oss.js'
  export default{
    props:{
      imageUrl:{
        type:String,
        default:""
      },
      clazz:{
        type:String,
        default:''
      }
    },
    data(){
      return{
        dialogVisible:false
      }
    },
    methods:{
      handleAvatarSuccess(res, file){
      },
      async beforeAvatarUpload(file){
       let url= await uploadOssFile(file);
       this.imageUrl=url;
       this.$emit('uploadSuccess',url);
        return false ;
      }
    }
  }
</script>
